#ifndef CAMERA_H
#define CAMERA_H

#include <QVector3D>
#include <QMatrix4x4>
#include <QKeyEvent>
#include <QOpenGLShader>//为了glfloat 这些变量，所以引进这个头文件
#include <QtMath>

enum CameraMovement
{
    FORWARD,
    BACKWARD,
    LEFT,
    RIGHT,
    UP,
    DOWN
};

//使用这些宏，可以很方便的修改初始化数据
const GLfloat YAW = -90.0f;
const GLfloat PITCH = 0.0f;
const GLfloat SPEED = 0.25;
const GLfloat SENSITIVITY = 0.1f;
const GLfloat ZOOM = 45.0f;

class Camera
{
public:
    Camera(QVector3D position = QVector3D(0.0f, 0.0f, 0.0f),
           QVector3D up = QVector3D(0.0f, 1.0f, 0.0f),
           GLfloat yaw = YAW, GLfloat pitch = PITCH);

    ~Camera();

    QMatrix4x4 getViewMatrix(); //返回lookat函数
    void processMouseMovement(GLfloat xoffset, GLfloat yoffset, GLboolean constraintPitch = GL_TRUE); //相应鼠标操作函数
    void processMouseScroll(GLfloat yoffset);//鼠标滚轮事件
    void processKeyboard(CameraMovement direction, GLfloat deltaTime);//键盘处理事件函数
    //void processInput(GLfloat dt);//键盘循环函数

    QVector3D position;
    QVector3D front;
    QVector3D up; //view坐标系 的上方向
    QVector3D right; // view坐标系的 右方向
    QVector3D worldUp;

    //Eular Angles
    GLfloat picth;
    GLfloat yaw;

    //Camera options
    GLfloat movementSpeed;
    GLfloat mouseSensitivity;
    GLfloat zoom;

private:
    void updateCameraVectors();
};

#endif // CAMERA_H
